<template>
  <div class="processRecord">
    <!-- 开班信息 -->
    <p-table
      size="middle"
      bordered
      rowKey="id"
      :pagination="false"
      :columns="startColumns"
      :dataSource="startData"
      :rowClassName="(record) => (record.judgeStatus == '1' ? 'mark-font' : '')"
    >
    </p-table>
    <p-table
      style="margin-top:20px"
      size="middle"
      bordered
      rowKey="id"
      :pagination="false"
      :columns="columns"
      :dataSource="tableData"
      :rowClassName="(record) => (record.judgeStatus == '1' ? 'mark-font' : '')"
    >
    </p-table>
  </div>
</template>
<script>
import process from "@/api/process";
import moment from "moment";
import {
  initDictOptions,
  filterMultiDictText,
} from "@/components/dict/JDictSelectUtil";

export default {
  inject: ["processInstanceId", "taskId", "processDefinitionKey"],
  prop: {
    dictOptions: {
      type: Array,
      default: () => null,
    },
  },
  data() {
    return {
      dictOptions: {},
      columns: [
        {
          title: "序号",
          key: "rowIndex",
          width: 60,
          align: "center",
          customRender(t, r, index) {
            return parseInt(index) + 1;
          },
        },
        { title: "检验项目", dataIndex: "testItemName", align: "center" },
        {
          title: "检验方式",
          dataIndex: "testMethod",
          align: "center",
          customRender: (text) => {
            console.log(text);
            if (!text.toString()) {
              return "";
            } else {
              return filterMultiDictText(this.dictOptions["method"], text + "");
            }
          },
        },
        {
          title: "检验结果",
          dataIndex: "testResult",
          align: "center",
          customRender(t, r, index) {
            return t == "0" ? "合格" : "不合格";
          },
        },
        {
          title: "检验判定",
          dataIndex: "judgeStatus",
          align: "center",
          customRender(t, r, index) {
            return t == "0" ? "合格" : "不合格";
          },
        },
      ],
      startColumns:[
        {
          title: "车间",
          dataIndex: "workroomname",
          align: "center",
        },
        {
          title: "组别",
          dataIndex: "classtimename",
          align: "center",
        },
        {
          title: "线体",
          dataIndex: "linename",
          align: "center",
        },
        {
          title: "产品编码",
          dataIndex: "productcode",
          align: "center",
        },
        {
          title: "工序工单",
          dataIndex: "processbillno",
          align: "center",
        },
        {
          title: "检验时间",
          dataIndex: "startDate",
          align: "center",
          customRender(t){
            return moment(t).format("YYYY-MM-DD hh:mm:ss");
          }
        },
        {
          title: "检验模板",
          dataIndex: "templateName",
          align: "center",
        },
        {
          title: "检验状态",
          dataIndex: "status",
          align: "center",
           customRender(t){
            if(t==0){
              return '未检验'
            }else if(t==1){
              return '已检验'
            }
          }
        },
      ],
      moment,
      readStatusMap: {
        1: "未读",
        2: "已读",
      },
      windowSize: true,
      startData: [],
      tableData: [
        /* {
          startTime: '创建时间',
          endTime: '处理时间',
          activityName: '节点名称',
          assigneeName: '执行人',
          readStatus: '1',
          operator: 'operator',
          comment: '处理意见',
        } */
      ],
      tableHeight: "450",
    };
  },
  computed: {},
  methods: {
    getList() {
      process.getStartlList(this.processInstanceId).then((res) => {
        if (res.code == 0) {
          this.startData = [res.data]
          let arr = [];
          res.data.details.forEach((item) => {
            if (item.testResult == 1) {
              arr.push(item);
            }
          });
          this.tableData = arr;
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    getDicOptions() {
      initDictOptions("mes_checkitemno", null).then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, "method", res.data);
        }
      });
    },
  },
  created() {
    this.getDicOptions();
  },
  mounted() {
    this.getList();
  },
};
</script>
<style lang="less">
.processRecord {
  overflow: hidden;
  .handing {
    color: #409efd;
  }
  .title-line {
    font-size: 16px;
    margin: 30px 0 10px 0;
  }
  .mark-font {
    color: red;
  }
}
</style>
